1. Field of the Invention
The present invention relates to a method, system, and computer program product for generating references to reusable code in a schema.
2. Description of the Related Art
Legacy applications, such as a third generation programming languages (e.g., Common Business-Oriented Language (COBOL), etc.) may utilize COPYBOOK or other “include” mechanisms to re-use data declarations for multiple programs or functions. The reusable sequences of code are placed into “COPY” files (“copybooks”) and achieve re-use by including the same copybook in multiple source files via the COBOL COPY statement. (Similar mechanisms are used in Java, C/C++ and other procedural languages.) The most typical sequence of code to re-use in COBOL is a data definition that repeats in multiple data structures.
FIG. 1a illustrates an example of two data structure definitions departmentUpdateRequest and departmentUpdateReply that may be included in a COBOL program, re-using the same copybook named COMMHDR. The COMMHDR copybook file would contain the reusable code. FIG. 1b illustrates an example of the reusable code in the COMMHDR copybook file.
A data modeling tool may generate Extended Markup Language (XML) schema equivalents of the COBOL copybooks. Such tools are used to expose COBOL legacy interfaces as services in a Service Oriented Architecture. These tools include for example, Rational Developer for System z (RD/z) Enterprise Service Tools components and CICS Transaction Server (CICS TS) Web Services Assistants. Then data modeling tools may generate an XML schema, such as an XSD file, for the different data structures in the COBOL program, such as the departmentUpdateRequest and departmentUpdateReply data structures, providing elements, attributes, and definitions of the data structures in the XML schema (XSD). The purpose of expressing the COBOL data structures as XML schemas is to expose their definitions and data to other systems and environments to provide non-COBOL systems and environments access to the data structures in the COBOL programs.
FIG. 2 illustrates an example of a schema generated for the departmentUpdateRequest data structure and FIG. 3 illustrates an example of a schema generated for the departmentUpdateReply data structure. Both of the schemas in FIGS. 2 and 3 include a declaration for the copybook element commHeader at statements 2 and 4, respectively, and a declaration for the namespace for the schemas for the copybook elements 6 and 8, respectively. In these examples, the differences in generation of the commHeader statement in the XML schema for the different data structures is the complex type name for each element as shown at reference numerals 2 and 4 in FIGS. 2 and 3, respectively, (“departmentupdaterequest_commheader” versus “departmentupdatereply_commheader”) and the namespaces for the schemas as shown at reference numerals 6 and 8 (“xmlns:cbl=″http://www.TST01I.com/schemas/TST01IInterface” versus “xmlns:cbl=http://www.TST01O.com/schemas/TST01OInterface).
Because a single copybook can be used in multiple data structure definitions, the current schema generators duplicate different typed elements for the copybook schemas in the different data structures, which expresses the copybook schema definitions as non-reusable, because their schema expression differs between data structures.
There is a need in the art for improved techniques for generating schemas for programs having data structures including references to reusable code.